package com.zmzncs.lmtc.module.customer.controller;

import com.zmzncs.lmtc.common.pojo.LoginUser;
import com.zmzncs.lmtc.common.pojo.Rest;
import com.zmzncs.lmtc.common.pojo.daoer.CreateMonth;
import com.zmzncs.lmtc.common.pojo.enums.WhetherEnum;
import com.zmzncs.lmtc.common.pojo.tengda.CarTypes;
import com.zmzncs.lmtc.common.util.JwtUtil;
import com.zmzncs.lmtc.common.util.RestUtil;
import com.zmzncs.lmtc.module.customer.service.CardService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.Map;


/**
 * <p>
 * 客户-会员卡 前端控制器
 * </p>
 *
 * @author 任建波
 * @since 2020-09-02
 */
@Api(tags = "客户会员卡")
@RestController
@RequestMapping("/customer/card")
public class CardController {

    @Autowired
    CardService cardService;

    @ApiOperation(value = "查询车辆类型")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", name = "token", value = "请求头token", required = true),
            @ApiImplicitParam(paramType = "query",name = "parkInfoId", value = "车场ID", required = true),
            @ApiImplicitParam(paramType = "query",name = "parkSource", value = "车场类型（1：泊链 2：咪网 3：道尔，4：腾达）", required = true),
    })
    @PostMapping(value = "car-types")
    public Rest<List<CarTypes>> getCarTypes(@NotNull Long parkInfoId,@NotNull Integer parkSource) {

        List<CarTypes> list = cardService.getCarTypes(parkInfoId,parkSource);
        if (list != null && list.size() > 0){
            return RestUtil.success(list);
        }
        return RestUtil.error();
    }

    @ApiOperation(value = "停车场月卡开户")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", name = "token", value = "请求头token", required = true),
    })
    @PostMapping(value = "park-creat-month")
    public Rest<String> parkCreatMonth(@RequestBody CreateMonth createMonth) {

        Map<String, String> map = cardService.parkCreatMonth(createMonth);
        String status = map.get("status");
        String message = map.get("message");
        if ("1".equals(status)){
            return RestUtil.success(message);
        } else {
            return RestUtil.error(message);
        }

    }

}

